package com.hylink.service;

import com.hylink.dao.UserDao;
import com.hylink.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by ryl
 */

@Service
public class UserService {

    @Autowired
    private UserDao userDao;

    public User getUserInfo(){
        User user=userDao.findUserInfo();
        return user;
    }

    public List<User> getAllUsers(){
        List<User> users = userDao.getAllUsers();
        return users;
    }


    /**
     * 翻页查询用户信息
     * @return
     */
    public  List<User> getUsesWithPager(Map<Object ,Object> map){
      List<User>  users = userDao.getUsesWithPager(map);
        return users;
    }

    public Integer count(Map<Object ,Object> map){
        return userDao.count(map);
    }


    public void saveUser(User user){
         userDao.saveUser(user);
    }
    public void updateUser(User user){
         userDao.updateUser(user);
    }





    public User getuserbyid(String id){
     return   userDao.getuserbyid(id);
    }


    public long  delete(String ids)
    {
        String[] ss = ids.split(",");
        long count= 0;
        for (String s : ss ) {
            userDao.delete(Integer.parseInt(s));
            count++;
        }
        return count;

    }

}